*do-file of paper

*------Codes ---------
*-Portable
gen portable=.
replace portable=1 if s01q36==1
replace portable=2 if s01q36==2
label define lab_portab 1 "Yesphone" 2 "nophone"
label value portable lab_portab
ta portable

*-Marital status
gen Hmstat = .
replace Hmstat = 1 if hmstat == 1 
replace Hmstat = 2 if hmstat == 2 | hmstat == 3 | hmstat == 4
replace Hmstat = 3 if hmstat == 6 | hmstat == 7
replace Hmstat = 4 if hmstat == 5 
label define lab_Hmstat 1 "Célibataire" 2 "Marié" 3 "Divorcé" 4 "Veufe" 
label value Hmstat lab_Hmstat
ta Hmstat

*-Ownership of off-farm land
gen posster=.
replace posster=1 if s16aq13==2 | s16aq13==4| s16aq13==6 | s16aq13==7 | s16aq13==1| s16aq13==1| s16aq13==5
replace possterr=0 if s16aq13==.
label define lab_possterr 0 "Pasdeterre" 1 "Possedeterre"  
label value posster lab_posster
ta possterr 

*Self-employement
gen traindépendant=.
replace traindépendant=1 if Hscip==1
replace traindépendant=0 if traindépendant==.

*-mobile money received
gen MM=.
replace MM=1 if s13aq16==4
replace MM=0 if MM==.


*Descriptive Statistics
sum ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender

*Results of the cross-tabulations
ta MM hgender, row nofreq
ta MM NE, row nofreq
ta MM Hscip, row nofreq
ta MM milieu, row nofreq
 
 
*Table 3: the extent of inequalities by gender and region of residence in Togo
*Gender
ineqdeco dtot if hgender==1
ineqdeco dtot if hgender==2

*Region
ineqdeco dtot if  region==0
ineqdeco dtot if  region==1
ineqdeco dtot if  region==2
ineqdeco dtot if  region==3
ineqdeco dtot if  region==4
ineqdeco dtot if  region==5


*--------------Representation of inequalities by region in Togo-----------
*-----GINI graphe
gen GINI=.
replace GINI=0.34290 if region==3
replace GINI=0.35015 if region==4
replace GINI=0.34792 if region==1
replace GINI=0.35512 if region==2
replace GINI=0.36399 if region==5
replace GINI=0.34682 if region==6

*Create average
collapse (mean) GINI, by(id)

*Access path 
cd "D:\02 01 23" 

shp2dta using TGO_adm1, database(RIM_database) coordinates(coord_rim) genid(id) genc(c)

use RIM_database, clear

*Merge
merge 1:1 id using "D:\02 01 23\GINI.dta"

*Graph
spmap GINI using coord_rim, id(id) fcolor(Blues) clnumber(5) title ("GINI by region in Togo") legstyle(2) legend(region(lcolor(black))) plotregion(icolor(stone)) graphregion(icolor(stone))



*-----Atkinson Index
gen Atkinson =.
replace Atkinson =0.18538 if id==1
replace Atkinson =0.18999 if id==4
replace Atkinson =0.18271 if id==3
replace Atkinson =0.19514 if id==2
replace Atkinson =0.20073 if id==5
replace Atkinson =0.18856 if id==6

*Create average
collapse (mean) Atkinson, by(id)

*Access path 
cd "D:\02 01 23" 

shp2dta using TGO_adm1, database(RIM_database) coordinates(coord_rim) genid(id) genc(c)

use RIM_database, clear

*Merge
merge 1:1 id using "D:\02 01 23\Atkinson.dta"

*Graph
spmap Atkinson using coord_rim, id(id) fcolor(Blues) clnumber(5) title ("Atkinson Index by region in Togo") legstyle(2) legend(region(lcolor(black))) plotregion(icolor(stone)) graphregion(icolor(stone))


*-----Theil Index
gen Theil=.
replace Theil=0.19331 if id==3
replace Theil=0.20846 if id==4
replace Theil=0.20780 if id==1
replace Theil=0.2190 if id==2
replace Theil=0.22536 if id==5
replace Theil=0.20125 if id==6

*Create average
collapse (mean) Theil, by(id)

*Access path 
cd "D:\02 01 23" 

shp2dta using TGO_adm1, database(RIM_database) coordinates(coord_rim) genid(id) genc(c)

use RIM_database, clear

*Merge
merge 1:1 id using "D:\02 01 23\Theil.dta"

*Graph
spmap Theil using coord_rim, id(id) fcolor(Blues) clnumber(5) title ("Indice de Theil par région au Togo") legstyle(2) legend(region(lcolor(black))) plotregion(icolor(stone)) graphregion(icolor(stone))



*-----Lorenz curve---------
*Contrefactuel
lorenz estimate dtot, graph(aspectratio(1))

*Traitement
lorenz estimate dtot, over(MM) graph(aspectratio(1))
lorenz graph, overlay aspectratio(1) xlabel(, grid)

lorenz estimate dtot, over(MM) graph(aspectratio(1))
lorenz graph, overlay aspectratio(1) xlabel(, grid)




*-------Decomposition of Oaxca-blinder by gender : with mobile money received-----
*National level
oaxaca ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant, by (hgender)
outreg2 using outreg2, ctitle(Oxaca) dec(3) word r2

*By regions
oaxaca ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant if region==1, by (hgender)
outreg2 using outreg2, ctitle(Maritime) dec(3) word r2
oaxaca ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant if region==2, by (hgender)
outreg2 using outreg2, ctitle(Plateaux) dec(3) word r2
oaxaca ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant if region==3, by (hgender)
outreg2 using outreg2, ctitle(Centrale) dec(3) word r2
oaxaca ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant if region==4, by (hgender)
outreg2 using outreg2, ctitle(Kara) dec(3) word r2
oaxaca ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant if region==5, by (hgender)
outreg2 using outreg2, ctitle(Savanes) dec(3) word r2
oaxaca ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant if region==6, by (hgender)
outreg2 using outreg2, ctitle(Lome-Cmmune) dec(3) word r2



*-----------Decomposition DER------
dpolag pali, hgroup(hgender) hsize(hhsize) fast(0)
dpolag pnali, hgroup(hgender) hsize(hhsize) fast(0)
dpolag partranfv, hgroup(hgender) hsize(hhsize) fast(0)




*---------------Variables instrumentale------
*OLS
reg ln_dtot MM hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender, ro
outreg2 using outreg2, ctitle(OLS) dec(3) word r2

*2SLS
ivreg2 ln_dtot hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender (MM = heduc possterr), robust endog(MM)
outreg2 using outreg2, ctitle(2SLS) dec(3) word r2

*Nationaux estimation 
sivqr ln_dtot hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender (MM = heduc possterr), quantile(.10) reps(100)
outreg2 using outreg2, ctitle(SIVQR) dec(3) word r2
sivqr ln_dtot hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender (MM = heduc possterr), quantile(.25) reps(100)
outreg2 using outreg2, ctitle(SIVQR) dec(3) word r2
sivqr ln_dtot hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender (MM = heduc possterr), quantile(.50) reps(100)
outreg2 using outreg2, ctitle(SIVQR) dec(3) word r2
sivqr ln_dtot hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender (MM = heduc possterr), quantile(.75) reps(100)
outreg2 using outreg2, ctitle(SIVQR) dec(3) word r2
sivqr ln_dtot hage age2 hhsize milieu portable Hmstat brchagri hreligion traindépendant hgender (MM = heduc possterr), quantile(.90) reps(100)
outreg2 using outreg2, ctitle(SIVQR) dec(3) word r2


